import Vue, { KeepAlive } from 'vue'
import Router from 'vue-router'
Vue.use(Router)
// 先把VueRouter原型对象的push保存一份
let originPush = Router.prototype.push
// 重写push||replace
// 第一个参数：告诉原来push方法,往哪儿跳(传递哪些参数)
Router.prototype.push = function (location, resolve, reject) {
  if (resolve && reject) {
    originPush.call(this, location, resolve, reject)
  } else {
    originPush.call(this, location, () => { }, () => { })
  }
}
export default new Router({
  routes: [
    {
      path: '/',
      name: 'login', //登录界面
      component: () => import('@/components/common/login'),
      meta:{KeepAlive:false}
    },
    {
      path: '/index', //教师主页
      component: () => import('@/components/admin/index'),
      meta:{KeepAlive:false},
      children: [
        {
          path: '/', //首页默认路由
          component: () => import('@/components/common/hello'),
          meta:{KeepAlive:false}
        },
        {
          path: '/grade', //学生成绩
          component: () => import('@/components/charts/grade'),
          meta:{KeepAlive:false}
        },
        {
          path: '/selectExamToPart', //学生分数段
          component: () => import('@/components/teacher/selectExamToPart'),
          meta:{KeepAlive:false}
        },
        {
          path: '/scorePart',
          component: () => import('@/components/charts/scorePart'),
          meta:{KeepAlive:false}
        },
        {
          path: '/allStudentsGrade', //所有学生成绩统计
          component: () => import('@/components/teacher/allStudentsGrade'),
          meta:{KeepAlive:false}
        },
        {
          path: '/examDescription', //考试管理功能描述
          component: () => import('@/components/teacher/examDescription'),
          meta:{KeepAlive:false}
        },
        {
          path: '/selectExam', //查询所有考试
          component: () => import('@/components/teacher/selectExam'),
          meta:{KeepAlive:false}
        },
        {
          path: '/addExam', //添加考试
          component: () => import('@/components/teacher/addExam'),
          meta:{KeepAlive:false}
        },
        {
          path: '/answerDescription', //题库管理功能介绍
          component: () => import('@/components/teacher/answerDescription')
          , meta: { KeepAlive: false }
        },
        {
          path: '/selectAnswer', //查询所有题库
          component: () => import('@/components/teacher/selectAnswer')
          , meta: { KeepAlive: false }
        },
        {
          path: '/addAnswer', //增加题库主界面
          component: () => import('@/components/teacher/addAnswer')
          , meta: { KeepAlive: false }
        },
        {
          path: '/addAnswerChildren', //点击试卷跳转到添加题库页面
          component: () => import('@/components/teacher/addAnswerChildren')
          , meta: { KeepAlive: false }
        },
        {
          path: '/studentManage', //学生管理界面
          component: () => import('@/components/teacher/studentManage')
          , meta: { KeepAlive: false }
        },
        {
          path: '/addStudent', //添加学生
          component: () => import('@/components/teacher/addStudent')
          , meta: { KeepAlive: false }
        },
        {
          path: '/teacherManage',
          component: () => import('@/components/admin/tacherManage')
          , meta: { KeepAlive: false }
        },
        {
          path: '/addTeacher',
          component: () => import('@/components/admin/addTeacher')
          , meta: { KeepAlive: false }
        }
      ]
    },
    {
      path: '/student',
      component: () => import('@/components/student/index'),
      meta: { KeepAlive: false },
      children: [
        { path: "/", component: () => import('@/components/student/myExam'), meta: { KeepAlive: false } },
        { path: '/startExam', component: () => import('@/components/student/startExam'), meta: { KeepAlive: false } },
        { path: '/manager', component: () => import('@/components/student/manager'), meta: { KeepAlive: false } },
        { path: '/examMsg', component: () => import('@/components/student/examMsg'), meta: { KeepAlive: false } },
        { path: '/message', component: () => import('@/components/student/message'), meta: { KeepAlive: false } },
        { path: '/studentScore', component: () => import("@/components/student/answerScore"), meta: { KeepAlive: false } },
        { path: '/scoreTable', component: () => import("@/components/student/scoreTable"), meta: { KeepAlive: false } }

      ]
    },
    {
      path: '/answer',
      component: () => import('@/components/student/answer'),
      meta: { KeepAlive: true }
    },
    {
      path: '/photo',
      component: () => import("@/components/student/photo"),
      meta: { KeepAlive: false }
    }
  ]
})
